
package com.github.ybq.parallaxviewpager.Interpolator;

import ohos.agp.components.AttrSet;
import ohos.app.Context;

/**
 * Decelerate interpolator
 */
public class DecelerateInterpolator extends BaseInterpolator {
    /**
     * M factor
     */
    private float mFactor = 0.6f;

    /**
     * Decelerate interpolator
     */
    public DecelerateInterpolator() {
    }

    /**
     * Decelerate interpolator
     *
     * @param factor factor
     */
    public DecelerateInterpolator(float factor) {
        mFactor = factor;
    }


    /**
     * Decelerate interpolator
     *
     * @param context context
     * @param attrs   attrs
     */
    public DecelerateInterpolator(Context context, AttrSet attrs) {
    }

    /**
     * Get interpolation float
     *
     * @param input input
     * @return the float
     */
    public float getInterpolation(float input) {
        float result;
        if (mFactor == 1.0f) {
            result = (float) (1.0f - (1.0f - input) * (1.0f - input));
        } else {
            result = (float) (1.0f - Math.pow((1.0f - input), 2 * mFactor));
        }
        return result;
    }


}
